{% extends "layout.html" %}

{% block title %}  修改密码  {% endblock %}

{%block nav%}

{% endblock %}

{% block body %}
<form method="post">
    <div class="form-group">
        <label for="name">用户名</label>
        <input id="name" name="name" type="text" class="form-control" placeholder="" value="{{current_user.name}}"
               readonly/>
    </div>
    <div class="form-group">
        <label for="email">用户邮箱</label>
        <input name="email" type="text" class="form-control" id="email" value="{{current_user.email}}" readonly/>
    </div>
    <div class="form-group">
        <label for="password">密码</label>
        <input name="password" type="password" id="password" class="form-control"/>
    </div>

    <div class="form-group">
        <label for="password_sure">确认密码</label>
        <input name="password_sure" type="password" id="password_sure" class="form-control"/>
    </div>

    <button type="button" id="submit" class="btn btn-default">提交</button>
</form>

<script type="text/javascript">
    $(function () {
        $("#submit").click(function () {
            var $password = $('#password').val();
            var $passwordConfirm = $('#password_sure').val();
            if ($password == $passwordConfirm) {
                $.post('/password/change', {password: $('#password').val()}, function (data) {
                    alert('修改成功');
                });
            } else {
                alert("密码和确认密码不相等")
            }

        });
    });
</script>
{% endblock %}